/**
 * 养修预约画面JS
 */

	var rootPath = getRootPath();
$(document).ready(function(){
	

	
	var openId = getQueryParamValue("openId");
	if (null != openId){
		$("#openId").val=openId;
	}

	
	$.ajax({
        type:"GET", 
        url:rootPath+"/wechat/api/maintain/getCarInfoByOpenID/"+$("#openId").val(), 
        dataType:"json",      
        async: false,
        contentType:"application/json",               
        data:null, 
        success:function(data){ 
            // 编辑轮播信息数据
			var wholeHtml = '';
			// 轮播（Carousel）指标
			var carousel_indicatorsHtml = '<ol class="carousel-indicators">';
			
			// 轮播（Carousel）项目
			var carousel_innerHtml = '<div class="carousel-inner">';
			
			
			$.each(data,function(carModelIndex,carModelObj){
				if (0 == carModelIndex){
					
				    carousel_indicatorsHtml+= '<li data-target="#myCarInfos" data-slide-to='+carModelIndex+' class="active"></li>';
				    carousel_innerHtml += "<div class='item active'>";
				    //品牌CODE赋值
				    $("#brandCode").val=carModelObj.brandCode;
				} else {
					carousel_indicatorsHtml+= '<li data-target="#myCarInfos" data-slide-to='+carModelIndex+' ></li>';
					carousel_innerHtml += "<div class='item'>";
				}
				
				carousel_innerHtml += '<img src="'+carModelObj.picUrl+'" width="150" height="150">';
				carousel_innerHtml +="<div class='carousel-caption'>";
				carousel_innerHtml += "<p>";
				carousel_innerHtml +="<h4>"+carModelObj.registNo+"</h4>";
				carousel_innerHtml +="<span class='text-muted'>"+carModelObj.seriesName+"</span>";
				carousel_innerHtml +="</div>";
				carousel_innerHtml +="</div>";
			});
			
			carousel_indicatorsHtml += "</ol> ";
			carousel_innerHtml += "</div>";
			
			// 轮播（Carousel）导航
			var carousel_controlHtml = '<a class="carousel-control left"  href="#myCarInfos"  data-slide="prev">&lsaquo;</a>';
			    carousel_controlHtml += '<a class="carousel-control right" href="#myCarInfos"  data-slide="next">&rsaquo;</a>';
			
			$("#myCarInfos").append(carousel_indicatorsHtml + carousel_innerHtml + carousel_controlHtml );
			
			$("#myCarInfos").carousel('pause');
        	
        },
        error:function(data){
        	alert("预约失败！");
        }
     });
	
});

/**
 * TO养修预约画面
 * @returns
 */
function to_maintain(){
	window.location = rootPath+"/views/maintain/maintain.html?brandCode="+$("#brandCode").val()+"&dealerCode="+$("#dealerCode").val()+"&openId="+$("#openId").val();
}

/**
 * TO一键急救援画面
 * @returns
 */
function to_sosHelp(){
	window.location = rootPath + "/views/maintain/sosHelp.html?brandCode="+$("#brandCode").val()+"&dealerCode="+$("#dealerCode").val()+"&openId="+$("#openId").val();
}